<!--
 * @Description: 住院收费
 * @Author: 梁青春
 * @Date: 2025-10-11 09:01:47
 * @LastEditTime: 2025-10-16 15:44:12
 * @LastEditors: 梁青春
-->
<template>
  <container :left-width="'320px'" :right-width="'400px'">
    <!-- 左侧患者列表区域 -->
    <template #left>
      <left />
    </template>

    <!-- 中间主要内容区域 -->
    <template #default>
      <div v-if="!selectedPatient" class="empty-state">
        <el-empty description="请从左侧选择患者查看详细信息" />
      </div>
      <Main v-else />
    </template>

    <!-- 右侧操作区域 -->
    <template #right>
      <div v-if="!selectedPatient" class="empty-operation">
        <el-empty description="请选择患者进行操作" />
      </div>
      <Right v-else />
    </template>
  </container>
</template>

<script setup name="InpatientBilling">
import Left from './components/Left.vue'
import Main from './components/Main.vue'
import Right from './components/Right.vue'
import Container from '@/components/Container/index.vue'

const selectedPatient = ref(true)

// 生命周期
onMounted(() => {
  // 组件挂载后的初始化操作
  console.log('住院收费页面已加载')
})
</script>

<style lang="scss" scoped>
.patient-list-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #f5f7fa;

  .page-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #e4e7ed;

    .page-title {
      margin: 0;
      font-size: 18px;
      font-weight: 600;
      color: #303133;
    }
  }

  .search-container {
    padding: 16px;
    background: white;
    border-bottom: 1px solid #e4e7ed;

    .search-input {
      :deep(.el-input__wrapper) {
        border-radius: 20px;
      }
    }

    .search-tip {
      margin-top: 8px;
      font-size: 12px;
      color: #909399;
    }
  }

  .status-tabs {
    padding: 16px;
    background: white;
    border-bottom: 1px solid #e4e7ed;

    .tab-container {
      position: relative;
      display: flex;
      background: #f5f7fa;
      border-radius: 6px;
      padding: 2px;

      .tab-item {
        flex: 1;
        text-align: center;
        padding: 8px 16px;
        cursor: pointer;
        font-size: 14px;
        color: #606266;
        border-radius: 4px;
        transition: all 0.3s;
        position: relative;
        z-index: 2;

        &.active {
          color: #409eff;
          background: white;
          box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }
      }

      .tab-indicator {
        position: absolute;
        top: 2px;
        bottom: 2px;
        width: 50%;
        background: white;
        border-radius: 4px;
        transition: left 0.3s;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        z-index: 1;
      }
    }
  }

  .patient-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;

    .patient-item {
      display: flex;
      align-items: center;
      padding: 12px;
      margin-bottom: 8px;
      background: white;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.3s;
      border: 2px solid transparent;

      &:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      }

      &.selected {
        border-color: #409eff;
        box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
      }

      .gender-icon {
        margin-right: 12px;

        .icon-wrapper {
          width: 28px;
          height: 28px;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          color: white;

          &.male {
            background: #409eff;
          }

          &.female {
            background: #f56c6c;
          }
        }
      }

      .patient-info {
        flex: 1;

        .patient-name {
          font-size: 16px;
          font-weight: 600;
          color: #303133;
          margin-bottom: 4px;
        }

        .patient-details {
          .detail-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2px;
            font-size: 12px;
            color: #909399;

            .department {
              color: #606266;
            }

            .charge-status {
              padding: 2px 6px;
              border-radius: 4px;
              font-size: 11px;

              &.unpaid {
                background: #fef0f0;
                color: #f56c6c;
              }

              &.paid {
                background: #f0f9ff;
                color: #67c23a;
              }

              &.partial {
                background: #fdf6ec;
                color: #e6a23c;
              }
            }
          }
        }
      }
    }
  }
}

.main-content {
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: #f5f7fa;

  .empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .patient-detail {
    .patient-info-card {
      margin-bottom: 20px;

      .card-header {
        font-weight: 600;
        color: #303133;
      }

      .info-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;

        .info-item {
          display: flex;
          align-items: center;

          label {
            font-weight: 500;
            color: #606266;
            margin-right: 8px;
            min-width: 80px;
          }

          span {
            color: #303133;
          }
        }
      }
    }

    .charge-detail-card {
      .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-weight: 600;
        color: #303133;

        .total-amount {
          .amount {
            color: #f56c6c;
            font-size: 18px;
            font-weight: 700;
          }
        }
      }
    }
  }
}

.operation-panel {
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: #f5f7fa;

  .empty-operation {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .operation-content {
    .operation-info {
      .patient-summary {
        margin-bottom: 20px;

        .summary-item {
          display: flex;
          justify-content: space-between;
          margin-bottom: 8px;

          label {
            color: #606266;
          }

          .amount {
            color: #f56c6c;
            font-weight: 600;
          }
        }
      }

      .payment-method {
        margin-bottom: 20px;

        label {
          display: block;
          margin-bottom: 8px;
          color: #606266;
          font-weight: 500;
        }
      }

      .operation-buttons {
        display: flex;
        flex-direction: column;
        gap: 12px;

        .el-button {
          width: 100%;
        }
      }
    }

    .charge-history {
      margin-top: 20px;

      .history-list {
        .history-item {
          display: flex;
          justify-content: space-between;
          align-items: center;
          padding: 12px 0;
          border-bottom: 1px solid #f0f0f0;

          &:last-child {
            border-bottom: none;
          }

          .history-info {
            .history-date {
              font-size: 12px;
              color: #909399;
            }

            .history-amount {
              font-weight: 600;
              color: #303133;
            }
          }

          .history-method {
            font-size: 12px;
            color: #606266;
          }
        }
      }
    }
  }
}

// 响应式设计
@media (max-width: 1200px) {
  .patient-detail .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .patient-list-container,
  .main-content,
  .operation-panel {
    padding: 12px;
  }

  .patient-item {
    padding: 8px !important;
  }
}
</style>
